<template>
  <div>
    <van-nav-bar :title="goodDetalis.name" left-text="返回" @click-left="onClickLeft" left-arrow>
      <template #right>
        <van-icon name="search" size="18" />
      </template>
    </van-nav-bar>
    <!-- 商品信息 -->
    <el-card class="box-card">
      <van-image :src="baseUrl+goodDetalis.url" width="100%"></van-image>
    </el-card>
    <el-card class="box-card" style="margin-top:5px">
      <van-row>
        <van-col :span="12"> <span class="decr" v-text="(goodDetalis.price).toFixed(0)+'积分'"></span></van-col>
        <van-col :span="12" style="text-align:right">
          <span class="decr" v-text="'销量'+(goodDetalis.price/20).toFixed(0)"></span>
          <span class="decr" v-text="'浏览量'+(goodDetalis.price/15).toFixed(0)"></span>
        </van-col>
      </van-row>
      <van-row style="margin-top:5px">
        <van-col :span="12"> <span class="decr" v-text="goodDetalis.name"></span></van-col>
      </van-row>
    </el-card>
    <!-- 规格 -->
    <el-card class="box-card" style="margin-top:5px">
      <van-row>
        <van-col :span="12"> <span class="decr">选择规格:</span></van-col>
        <van-col :span="12" style="text-align:right">
          <van-icon name="arrow" />
        </van-col>
      </van-row>
    </el-card>
    <!-- 底部 -->
    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服" color="#ee0a24" />
      <van-goods-action-icon icon="cart-o" text="购物车" />
      <van-goods-action-icon icon="star" text="已收藏" color="#ff5000" />
      <van-goods-action-button type="warning" text="加入购物车" />
      <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action>
  </div>
</template>
<script>
import { listGoods, goodsTeam, goodsHot, } from "@/api/good/goods";

export default {
  data () {
    return {
      goodsList: [],
      id: '',
      goodDetalis: []
    }
  },
  created () {
    this.getGoodsList()
  },
  methods: {
    getGoodsList () {
      this.id = this.$route.params.id
      listGoods().then(res => {
        this.goodsList = res.data
        for (var i = 0; i < this.goodsList.length; i++) {
          if (this.goodsList[i].id == this.id) {
            var obj = this.goodsList[i]
            localStorage["save"] = JSON.stringify(obj);
          }
        }
        this.goodDetalis = JSON.parse(localStorage.getItem("save"))
      })
    },
    onClickLeft () {
      this.$router.go(-1);
    },
  }
}
</script>
<style scoped>
</style>